//
//  ScSearchView.swift
//  weibo03
//
//  Created by mac on 16/9/20.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class ScSearchView: UIView {

    @IBOutlet weak var rightSearchCons: NSLayoutConstraint!
    
    @IBOutlet weak var searchButton: UIButton!
    
    @IBOutlet weak var searchTextField: UITextField!
    
    
    @IBAction func editBegin(_ sender: AnyObject) {
        
        rightSearchCons.constant = searchButton.width
        
        UIView.animate(withDuration: 0.3) {
            self.layoutIfNeeded()
        }
    }
  
    @IBAction func searchBtn(_ sender: AnyObject) {
        //  失去第一响应者
        searchTextField.resignFirstResponder()
        rightSearchCons.constant = 0
        UIView.animate(withDuration: 0.3) {
            self.layoutIfNeeded()
        }

    }
    //使用类方法 创建xib对象
    class func searchView() -> ScSearchView {
        return UINib(nibName: "ScSearchView", bundle: nil).instantiate(withOwner: nil, options: nil).last! as! ScSearchView
    }
    
}
